From e276f1e8444383ea065c1ebb0c5f91441aa89db9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Sun, 2 Jul 2017 14:16:09 +0200 Subject: [PATCH] label: Fix get_layout_index Properly translate the given coordinates to layout coordinates. Fixes clicking links and selecting text. --- gtk/gtklabel.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index a7107511e3..5b5525f0fa 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -4183,25 +4183,6 @@ gtk_label_unmap (GtkWidget *widget) GTK_WIDGET_CLASS (gtk_label_parent_class)->unmap (widget); } -static void -window_to_layout_coords (GtkLabel *label, - gint *x, - gint *y) -{ - GtkAllocation allocation; - gint lx, ly; - - /* get layout location in widget->window coords */ - get_layout_location (label, &lx, &ly); - _gtk_widget_get_allocation (GTK_WIDGET (label), &allocation); - - *x += allocation.x; /* go to widget->window */ - *x -= lx; /* go to layout */ - - *y += allocation.y; /* go to widget->window */ - *y -= ly; /* go to layout */ -} - static gboolean get_layout_index (GtkLabel *label, gint x, @@ -4213,12 +4194,16 @@ get_layout_index (GtkLabel *label, const gchar *cluster; const gchar *cluster_end; gboolean inside; + int lx, ly; *index = 0; gtk_label_ensure_layout (label); + get_layout_location (label, &lx, &ly); - window_to_layout_coords (label, &x, &y); + /* Translate x/y to layout position */ + x -= lx; + y -= ly; x *= PANGO_SCALE; y *= PANGO_SCALE; -- 2.30.2